using System;
using System.Data;
namespace AppToolKit.Data
{
	public class ReaderWapper : IDisposable
	{
		private IDataReader reader_;
		public ReaderWapper(IDataReader reader)
		{
			this.reader_ = reader;
		}
		public void Process(ExecuteReaderCallback callback)
		{
			try
			{
				if (callback != null)
				{
					callback(this.reader_);
				}
				this.reader_.Close();
				this.reader_.Dispose();
			}
			catch
			{
				this.reader_.Close();
				this.reader_.Dispose();
				throw;
			}
		}
		public void Dispose()
		{
			this.reader_.Close();
			this.reader_.Dispose();
		}
	}
}
